﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ScoreManager : MonoBehaviour {

    private int score;

    private Text m_scoreUI;

    public int Score
    {
        get
        {
            return score;
        }
    }

    private void Awake()
    {
        m_scoreUI = GameObject.Find("Score").GetComponent<Text>();
    }

    void Start () {
        score = 0;
        UpdateScoreUI();
	}

    /// <summary>
    /// 加分函数，内含 UI更新
    /// </summary>
    /// <param name="num"></param>
    public void AddScore(int num)
    {
        this.score += num;
        UpdateScoreUI();
    }


    /// <summary>
    /// 更新分数UI
    /// </summary>
    private void UpdateScoreUI()
    {
        m_scoreUI.text = "Score: " + score;
    }
}
